package com.example.demo.api.controller;

import com.example.demo.api.dto.UserDTO;
import com.example.demo.domain.entity.User;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @GetMapping
    public Long get(Long id){
        return id*100;
    }

    @PostMapping
    public String post(@RequestBody User user){
        return user.toString();
    }

    @PutMapping
    public UserDTO put(@RequestBody User user){
        UserDTO userDTO=new UserDTO();
        BeanUtils.copyProperties(user,userDTO);
        userDTO.setMark("已成年");
        return userDTO;
    }

    @DeleteMapping
    public String delete(@RequestBody User user){
        return user.getName()+"信息已删除+";
    }
}
